package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.DuijiangBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.DuijiangViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by NEUSOFT on 2017/10/11.
 */

public class DuijiangAdapter extends BaseListAdapter {
    public DuijiangAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView=layoutInflater.inflate(R.layout.item_duijiang,parent,false);
        DuijiangViewHolder holder=new DuijiangViewHolder(itemView);
        return holder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        DuijiangViewHolder duijiangViewHolder=(DuijiangViewHolder) holder;
        final DuijiangBean duijiangBean = (DuijiangBean)data.get(position);

        final String duijiangname =duijiangBean.getG_name();
        String duijianginfo=duijiangBean.getG_infos();
        final String duijiangstate=duijiangBean.getGr_state();

        duijiangViewHolder.duijiangnameView.setText(duijiangname);
        duijiangViewHolder.duijianginfoView.setText(duijianginfo);
        duijiangViewHolder.duijiangstateView.setText(duijiangstate);
        String pic = BASE_URI+"giftpic/"+duijiangBean.getG_pic();
        Picasso.with(context)
                .load(pic)
                .placeholder(R.drawable.ic_cook_holder)
                .error(R.drawable.ic_cook_holder_error)
                .into(DuijiangViewHolder.imageView);
    }
}
